<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/4/30
 * Time: 11:09
 */

namespace frontend\components\behaviors;

use Yii;

class UserTypeBehavior extends \yii\base\ActionFilter
{
    public $chessUserType;

    public function beforeAction($action)
    {
        $user = Yii::$app->user->currentUser;
        $currentChess = $user->getCurrentChess();
        if ($currentChess->type != $this->chessUserType) {
            throw new \yii\web\NotFoundHttpException(Yii::t('app.c2', 'Chess user type has been change.'));
        }
        return parent::beforeAction($action); // TODO: Change the autogenerated stub
    }

}